<template >
  <div class="detail" v-if="Object.keys(filmData).length">
    <div class="img">
      <img :src="filmData.movieposter" style="width: 100%" alt="" />
    </div>
    <div class="box">
      <div class="title">
        {{ filmData.name }}
        <b>3D</b>
        <span>{{ filmData.filmScore + "分" }}</span>
      </div>
      <div class="xx">{{ filmData.type.join("|")}}</div>
      <div class="xx">上映时间: {{ filmData.timeStart }}</div>
      <div class="xx">{{ filmData.areaCountry }} | 120分钟</div>
      <div class="xx" :class="infoIs==2?'show':'hide'" ref="infobox" style="margin-top:17px">{{ filmData.filmintroduction }}</div>
     <div style="text-align: center;" v-if="infoIs==1" @click="infoIs=2"> <i class="iconfont icon-xiangxia"></i></div>
     <div style="text-align: center;" v-if="infoIs==2"  @click="infoIs=1"> <i class="iconfont icon-icchevronless"></i></div>
    </div>

    <div class="ticket">购票</div>
  </div>
  <div class="back" @click="back">
    <i class="iconfont icon-xiangzuo"></i>
  </div>
</template>

<script setup>
import moment from "moment";
import bus from "vue3-eventbus";
import { getFilmInfo } from "@/api/index.js";
import { ref } from "@vue/reactivity";
import { nextTick, onBeforeUnmount, onMounted } from "@vue/runtime-core";
import { useRoute,useRouter } from "vue-router";
let router=useRouter()
let route = useRoute();
let id = route.params.filmid;
let infoIs =ref(1)

let filmData = ref({});
let length = ref(0);
let infobox=ref(null)

async function getData() {
  let res = await getFilmInfo(id);
  console.log(res);
  filmData.value = res.data;
  nextTick(()=>{
    if(infobox.value.offsetHeight<=41){
      infoIs.value=0
    }
  })
}
function back(){
  router.go(-1)
}

getData();
onMounted(() => {
  bus.emit("footerShow", false);
});
onBeforeUnmount(() => {
  bus.emit("footerShow", true);
});

</script>

<style lang="less" scoped>
.detail {
  .swiper {
    width: 100%;
    overflow: hidden;
  }
  .swiper-slide {
    img {
      width: 80px;
    }
  }

  .img {
    width: 100%;
    height: 260px;
    overflow: hidden;

    img {
      width: 100%;
    }
  }
}

.ticket {
  position: fixed;
  bottom: 0;
  z-index: 999;
  width: 100%;
  height: 60px;
  background-color: #ff5f16;
  color: whitesmoke;
  line-height: 60px;
  text-align: center;
  font-size: 20px;
}

.back {
  position: fixed;
  top: 10px;
  left: 10px;

  i {
    padding: 5px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, .4);
  }
}

.icon-fanhui1 {
  color: orangered;
}

.box {
  padding: 15px;
  padding-top: 12px;
  background-color: #fff;
  .title {
    color: #191a1b;
    font-size: 18px;
    height: 24px;
    line-height: 20px;
    margin-right: 7px;

    span {
      float: right;
      text-align: right;
      color: #ffb232;
      font-style: italic;
    }

    b {
      font-size: 9px;
    color: #fff;
    background-color: #d2d6dc;
    height: 14px;
    line-height: 14px;
    padding: 0 2px;
    border-radius: 2px;
    display: inline-block;
    margin-top: -4px;
    }
  }

  .xx {
    font-size: 13px;
    color: #797d82;
    margin-top: 8px;
    line-height: 20px;
    transition: all 0.5s;
    overflow: hidden;
  }

  .hide {
    max-height: 42px;
  }

  .show {
    max-height: 200px;
  }
}

.iconfont{
  font-family: 'iconfont' !important;
  font-size: .16rem;
  font-style: normal;
  -webkit-font-smoothing:antialiased;
}
</style>
